#include <iostream>
#include <jsoncpp/json/json.h>

int main()
{
	Json::Value p;
	p["hello"] = "hello";
	p["world"] = "world";
	Json::Value root;
	root["x"] = 100;
	root["y"] = 200;
	root["op"] = '+';
	root["test"] = p;
	root["desc"] = "this is a + oper";

	Json::FastWriter f;
	Json::StyledWriter s;

	std::string res = s.write(root);
	std::cout << res << std::endl;

	Json::Reader r;
	Json::Value v;
	bool t = r.parse(res,v);
	if(!t) return -1;
	int x = v["x"].asInt();
	int y = v["y"].asInt();
	char op = v["op"].asInt();
	std::string desc = v["desc"].asString();
	std::string s1 = v["test"]["hello"].asString();
	std::string s2 = v["test"]["world"].asString();
	std::cout << x << std::endl;
	std::cout << y << std::endl;
	std::cout << op << std::endl;
	std::cout << desc << std::endl;
	std::cout << s1 << std::endl;
	std::cout << s2 << std::endl;

	return 0; 
}
